const { regeneratorRuntime } = global

Page(global.connect(
  state => ({
    ...state.globalReducer,
    ...state.profileReducer
  }),
  dispatch => ({
    handleRoute: global.handleRoute,
    handleLicon1Tap(e) {
      console.log('handleLicon1Tap', e)
      wx.navigateBack()
    },
    async handleGetSMSCode(e) {
      console.log('handleGetSMSCode')
      if (this.data.uiCodeCount === 60) {
        const actionRes = await dispatch(global.profileReducer.getAuditSendCode({
          phone: this.data.ori_phone
        }))
        if (actionRes.actionStatus !== 'SUCCESS') {
          this.selectComponent('#toast').handleShow({
            message: actionRes.apiMes
          })
        }
      }
    },
    async handleSubmit(e) {
      console.log('handleSubmit', e.detail.value)
      const actionRes = await dispatch(global.profileReducer.updatePhone(e.detail.value))
      console.log(actionRes)
      if (actionRes.actionStatus === 'SUCCESS') {
        this.selectComponent('#toast').handleShow({
          type: 'success',
          message: actionRes.apiMes
        })
        setTimeout(() => {
          wx.navigateBack()
        }, 1000);
      } else {
        this.selectComponent('#toast').handleShow({
          message: actionRes.apiMes
        })
      }
    }
  })
)({
  data: {
    ori_phone: ''
  },
  onLoad() {
    console.log('modphone onload')
  },
  handleInput(e) {
    console.log(e)
    const { value } = e.detail
    this.setData({ ori_phone: value })
  }
}))